home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
js
/
common-src.js
< prev
next >
Wrap
Text File
|
2010-05-19
|
70KB
|
2,079 lines
var D=document, W=window;
/**
* General purpose functions
*/
function dgi(o){return document.getElementById(o)}
// D.getElementsByName, use nb="all" to get array
function dgn(obn,nb){
if(!D.getElementsByName(obn).length) return;
if(nb=='all') return D.getElementsByName(obn);
if(nb==undefined || isNaN(nb)) nb=0;
return D.getElementsByName(obn)[nb];
}
function windowStop(){if(W.stop) W.stop(); else D.execCommand("Stop");wl.asr.cancelAll()}
function fas(p2,p3,p4,p5,as){fillAndSubmit(p2,p3,p4,p5,as)}
function ping() {sendData('rnd='+Math.random(), '/ping.php', true);}
function cfDbg(obj,add,opt){
if(this.nb==undefined) this.nb=0;
if(this.nb++>30) return
var n,elem,o='',i=-40;
if(typeof obj!='object') o=obj;
else{
if(!opt) opt={};
while(i++<0) o+='------'; o+="\n"+(obj.id?'id='+obj.id+'/':'')+"\n";
for(elem in obj) if((!opt.noOn||elem.substr(0,2)!='on') && (!opt.noEmpty||obj[elem]!=='')){
o+=i+':'+elem+' ('+typeof(obj[elem])+')='+((!opt.det && (typeof(obj[elem])=='object' || typeof(obj[elem])=='function' || elem=='innerHTML' ||elem=='outerHTML'))?'[obj]':obj[elem])+(((++i)%3==0)?"\n":' ');
}
}
if(add===undefined||add===false) return alert(o);
o=o.toString().replace('/</g','<').replace(/\n/g,'<br>');
if(!(n=dgi("dbg"))){
n=D.createElement('DIV');
n.id="dbg";
with(n.style){position='absolute';top='0px';left='0px';}
D.body.appendChild(n)
}
n.innerHTML=((add>0)?n.innerHTML:'')+o;
}
D.oncontextmenu=function(e){if(W.onrightclick && ((e && e.which == 3)||(W.event && (event.button==0||event.button==2)))) return onrightclick(e); else return true}
// Count associative array items
function count(a){var n=0; for(e in a) n++; return n;}
// String trim
String.prototype.trim = function (){return this.replace(/^\s+|\s+$/,'');};
/**
* DOM Functions
*/
function removeNode(n){if(n.parentNode) n.parentNode.removeChild(n)}
// Get actual style value
function getElementStyle(elem, styleProp, keepPx) {
if(!elem) return false;
if(phpBrowser=='ie' && styleProp.indexOf('-')!=-1){
styleProp=styleProp.substr(0,styleProp.indexOf('-'))+styleProp.substr(styleProp.indexOf('-')+1,1).toUpperCase()+styleProp.substr(styleProp.indexOf('-')+2);
}
if(keepPx){
if(W.GetComputedStyle) return W.getComputedStyle(elem, "").getPropertyValue(styleProp); // Gecko
if (elem.currentStyle) return elem.currentStyle[styleProp];// Opera & IE
return '';
}
if(W.getComputedStyle) es=W.getComputedStyle(elem, "").getPropertyValue(styleProp); // Gecko
else if (elem.currentStyle) es=elem.currentStyle[styleProp];// Opera & IE
else return '';
if(es.substr(es.length-2)=='px') es=es.substr(0,es.length-2);
else if(es.substr(es.length-2)=='em') { es=es.substr(0,es.length-2)*getElementStyle(elem,'font-size');}
if(keepPx===false&&es=='auto') return 0;
return es;
}
function actualOffsetLeft(node){
var l=0;
while(node) {
l+=node.offsetLeft;
if(node.style && ((ov=node.style.overflow)=='scroll' || ov=='auto')) l-=(node.scrollLeft)
node=node.offsetParent;
}
return l;
}
function actualOffsetRight(node){return actualOffsetLeft(node)+node.offsetWidth}
function actualOffsetTop(node){
var t=0;
while(node) {
t+=node.offsetTop;
if(!(node=node.offsetParent)) break;
if(node.style && ((ov=node.style.overflow)=='scroll' || ov=='auto')) t-=(node.scrollTop)
}
return t;
}
function actualOffsetBottom(node){return actualOffsetTop(node)+node.offsetHeight}
function actualRect(node){
var rect={x:0,y:0,w:node.offsetWidth,h:node.offsetHeight};
while(node) {
rect.x+=node.offsetLeft;
rect.y+=node.offsetTop;
if((ov=node.style.overflow)=='scroll' || ov=='auto') {
rect.x-=(node.scrollLeft)
rect.y-=(node.scrollTop)
}
node=node.offsetParent;
}
return rect;
}
function setActualHeight(node, h){
if(phpBrowser=="ie") {try{node.style.height = h} catch(err){};}
else node.style.height = (h - getElementStyle(node,'padding-top') - getElementStyle(node,'border-top-width') - getElementStyle(node,'padding-bottom') - getElementStyle(node,'border-bottom-width'))+'px';
}
function setActualWidth(node, w){
if(phpBrowser=="ie") {try{node.style.height = h} catch(err){};}
else node.style.width = (w - getElementStyle(node,'padding-left') - getElementStyle(node,'padding-right'))+'px';
}
function isParent(pn,cn){
var n=cn; var i=10;
while(--i&&(n=n.parentNode)) if(n==pn) return 1;
return 0;
}
function alignBottom(child, parent, margin){
var h;
if(!child || !parent) return;
if(!margin)margin=0;
if(W.winMe && parent==winMe) h=winMe.getInnerHeight();
else h=actualOffsetBottom(parent)-getElementStyle(parent,'padding-bottom',false);
h+=-actualOffsetTop(child)-getElementStyle(child,'margin-bottom',false)-margin;
setActualHeight(child,h);
return h;
}
// Connect listener to object. args: node, event (without "on"), callback
function connect() {
var a = arguments;
return D.addEventListener?a[0].addEventListener(a[1],a[2],a[3] || false):a[0].attachEvent?a[0].attachEvent('on' + a[1], a[2]): false;
}
function disconnect() {
var a = arguments;
return D.removeEventListener?a[0].removeEventListener(a[1],a[2],a[3] || false):a[0].detachEvent?a[0].detachEvent('on' + a[1], a[2]): false;
}
if(!W.stopPropagation) stopPropagation = function (e){e.cancelBubble=true;}
/**
* Hover
*/
var currentHover=0;
function eHover(e){
if(!e) {if(currentHover) eHoverO(currentHover); currentHover=0; return}
var targ=e.target||e.srcElement;
var limit=10;
while(--limit>0 && targ && (!targ.getAttribute || !targ.getAttribute('eH'))) targ=targ.parentNode;
//alert(dbgObj(targ))
if(limit && targ){
if(!targ.id) targ.id="H"+Math.random();// Create id if element doesn't have one
if(targ.id && currentHover!=targ.id) eHoverI(targ.id);
if(currentHover && currentHover!=targ.id) {eHoverO(currentHover); currentHover=0;}
currentHover=targ.id;
}
else if(currentHover) {eHoverO(currentHover); currentHover=0;}
}
function eHoverI(objectid, classToSet){
if((W.dragInProgress && dragInProgress) || !(obJ=dgi(objectid))) return;
var cClass=obJ.className; var rClass='';
if((spP=cClass.indexOf(' '))!=-1) {rClass=cClass.substr(spP);cClass=cClass.substr(0,spP);}
if(classToSet) return obJ.className=classToSet+rClass;
if(cClass.length<5 || cClass.substr(cClass.length-5,5)!='Hover') obJ.className=cClass + 'Hover'+rClass;
}
function eHoverO(objectid, classToSet){
if(!(obJ=dgi(objectid)) || (W.dragInProgress && dragInProgress)) return;
var cClass=dgi(objectid).className; var rClass='';
if((spP=cClass.indexOf(' '))!=-1) {rClass=cClass.substr(spP);cClass=cClass.substr(0,spP);}
if(classToSet) return dgi(objectid).className=classToSet+rClass;
if(cClass.substr(cClass.length-5,5)=='Hover') dgi(objectid).className=cClass.substr(0,cClass.length-5)+rClass;
}
// Change an image or IE6 png span SRC
function changeImgSrc(id,imgUrl){
if(dgi(id).tagName.toLowerCase()=='img') dgi(id).src=imgUrl;
else {
var filter=dgi(id).style.filter;
var s=filter.indexOf("src='")+5;
var e=filter.indexOf("'",s);
dgi(id).style.filter=filter.substr(0,s) + imgUrl + filter.substr(e);
}
}
/**
* Collapse TD
* @param id: id of folded / unfolded TD
*/
function toggleTD(id){
var cTD=dgi(id)/* folded / unfolded TD /*/, cTDS=cTD.style, ctrl=dgi(id+'_colTD') /* handle TD */,isFolded=(cTDS.display=='none'),extraParameters={},cTDDiv1S,cTDDiv2,cTDDiv2S,baseWidth;
ctrl.lastChild.className=isFolded?'colTDUF':'colTDF';
ctrl.title=isFolded?hideCaption:showCaption;
// Toggle server-side state
sendData("toggleTD=1&"+id+"="+(isFolded?1:0),PHP_SELF,0);
// Add a double div wrapper into collapsed TD so width can be properly set
if(cTD.firstChild.id!==id+'_colTDD1'){
cTD.innerHTML='<div id="'+id+'_colTDD1" style="overflow:hidden;position:relative"><div id="'+id+'_colTDD2">'+cTD.innerHTML+'</div></div>';
}
cTDDiv1S=dgi(id+'_colTDD1').style;
cTDDiv2=dgi(id+'_colTDD2'); cTDDiv2S=cTDDiv2.style;
// Unfolding
if(isFolded){
// Compute unfolded width
cTDS.width=cTDDiv1S.width='1px';
cTDDiv2S.position='absolute'
//cTDDiv2S.visibility='hidden';
cTDS.display=isFolded?'':'none';
baseWidth=cTDDiv2.offsetWidth;
cTDDiv2S.position='';
wl.anim({'item':cTD,
'duration':500,
'extraParameters':{'baseWidth':baseWidth},
'callbackComplete':function(){if(W.winResized) winResized();if(W.dd) dd.recalc()},
'function':function(p,anim){
p=Math.max(1,(anim.extraParameters.baseWidth*wl.animFunctionUnfold1(p)))+'px';
cTDDiv1S.width=p;
return {'width':p}
}
});
}
// Folding
else{
baseWidth=cTD.offsetWidth
extraParameters.startW=cTD.offsetWidth;
cTDDiv1S.width=baseWidth+'px';
wl.anim({'item':cTD,
'duration':500,
'extraParameters':{'baseWidth':baseWidth},
'callbackComplete':function(){
cTDS.display='none';
if(W.winResized) winResized();if(W.dd) dd.recalc()
},
'function':function(p,anim){
p=Math.max(1,(anim.extraParameters.baseWidth*wl.animFunctionFold1(p)))+'px';
cTDDiv1S.width=p;
return {'width':p}
}
});
}
if(W.winResized) winResized();
}
function toggleTDHL(n){
var id=n.id;
if(!id) return;
id=id.substr(0,id.length-6);
if(dgi(id).style.display=='none') {
if(!dd.obj || dd.obj.id!=='dragMaskDiv') toggleTD(id);
}
}
/**
* Fade in-out (0 <= alpha <= 1)
* i: item or id of item
* aSt: alpha start
* aEn: alpha target
* nbSteps: nb of steps
* cb: js callback on completition (eval'ed)
* stepCb: js callback on each step (eval'ed)
*/
function fade(i, aSt, aEn, nbSteps, cb, stepCb, aCur){
if(typeof(i)=='object'){if(i.id) i=i.id; else i=i.id='id'+Math.floor(999999*Math.random());}
if(wl.fadeItems[i] && wl.fadeItems[i]!=aEn) return; // Another fadeto has set a new target alpha
var ini,finished=0,n=dgi(i),s=n.style;
// Simple onload fade: use new animation function
if(aSt===undefined){
if($(n).e.getStyle('visibility')!=='visible') s.visibility='visible';
if($(n).e.getStyle('display')=='none') s.display='inline';
wl.anim({'item':n,'duration':500,'function':function(p,a){
return {'opacity':p}}
});
return;
}
if(aSt==undefined) {aSt=0;aEn=1}
if(aEn==undefined) aEn=aSt;
if(nbSteps==undefined) {
if(aSt==aEn) nbSteps=1; else nbSteps=imgFadeSteps;
}
if(aCur==undefined) {aCur=aSt;ini=1;}
aCur+=(aEn-aSt)/nbSteps;
if(!n) return;
if(aEn > aSt && aCur >= aEn){finished=1;aCur=aEn;}
if(aEn <= aSt && aCur <= aEn){finished=1;aCur=aEn;}
setAlpha(n,aCur);
if(aCur>0 && ini && (s.display=="none" || s.visibility!="visible")) {s.display=""; s.visibility="visible"}
if(aCur==0) s.display="none";
if(!finished) W.setTimeout('fade("'+ i +'", '+aSt+', '+aEn+', '+nbSteps+', \''+cb+'\', \''+stepCb+'\', '+aCur+')',5);
else{
if(cb!==undefined && cb!==false) eval(cb);
if(wl.fadeItems[i]!==undefined) delete(wl.fadeItems[i]);
}
if(stepCb) eval(stepCb);
}
// Set opacity (0<=alpha<=1)
function setAlpha(n,alpha){
with(n.style){
if(alpha==1) {
var s
if((s=n.getAttribute('style')) && s.removeAttribute) s.removeAttribute('filter')
opacity='';
}
else {
filter="Alpha(opacity="+(Math.round(100*alpha))+")";
opacity=Math.round(100*alpha)/100;
}
}
}
/**
* Fold/unfold
*/
function fold(itemId,onFoldedFunction){
var item=dgi(itemId);
if(item.style.overflow!='hidden') item.style.overflow='hidden';
var h=item.offsetHeight;
if(h<11){
item.style.height='0';
if(onFoldedFunction) eval(onFoldedFunction+'("'+itemId+'")');
}
else{
item.style.height=(h*0.6)+'px';
W.setTimeout('fold("'+itemId+'"'+((onFoldedFunction)?',"'+onFoldedFunction+'")':')'),1);
}
}
function unfold(itemId,unfoldedHeight,onUnFoldedFunction){
var item=dgi(itemId);
if(item.style.overflow!='hidden') item.style.overflow='hidden';
var h=Math.max(item.offsetHeight,10)*1.4;
if(h>=unfoldedHeight){
item.style.unfoldedHeight=h+'px';
}
else{
item.style.height=h+'px';
W.setTimeout('unfold("'+itemId+'",'+unfoldedHeight+((onUnFoldedFunction)?',"'+onUnFoldedFunction+'")':')'),1);
}
}
/**
* Buttons (bt)
*/
function btEnable(id){
dgi(id).getElementsByTagName('a')[0].className="up";
if(dgi(id).getElementsByTagName('legend')[0].innerHTML) dgi(id).getElementsByTagName('a')[0].href=dgi(id).getElementsByTagName('legend')[0].innerHTML;
}
function btDisable(id){
dgi(id).getElementsByTagName('a')[0].className="off";
if(dgi(id).getElementsByTagName('a')[0].href!="javascript:;") dgi(id).getElementsByTagName('legend')[0].innerHTML=dgi(id).getElementsByTagName('a')[0].href;
dgi(id).getElementsByTagName('a')[0].href="javascript:;";
}
function btActivate(id){
if(dgi(id).getElementsByTagName('a')[0].className=="off"){
if(dgi(id).getElementsByTagName('legend')[0].innerHTML) dgi(id).getElementsByTagName('a')[0].href=dgi(id).getElementsByTagName('legend')[0].innerHTML;
}
dgi(id).getElementsByTagName('a')[0].className="on";
}
function btState(id){return dgi(id).getElementsByTagName('a')[0].className;}
function btSetCaption(id,t){
dgi(id).getElementsByTagName('q')[0].innerHTML=t;
if(phpBrowser=='ie') dgi(id).getElementsByTagName('s')[0].innerHTML=t;
btAdjustText(id);
}
function btSetIcon(id,s){
dgi(id).getElementsByTagName('IMG')[0].src=s;
btAdjustText(id);
}
function btAdjustText(id){
if(phpBrowser=='ie') return;
var txt=dgi(id).getElementsByTagName('s')[0].innerHTML;
if(dgi(id).getElementsByTagName('q')[0].innerHTML.length) txt=dgi(id).getElementsByTagName('q')[0].innerHTML;
else dgi(id).getElementsByTagName('q')[0].innerHTML=txt;
dgi(id).getElementsByTagName('s')[0].innerHTML=txt;
var txtArea=dgi(id).getElementsByTagName('s')[0];
var buttonArea=dgi(id).getElementsByTagName('u')[0];
var dots='...';
if(!dgi(id).title) dgi(id).title=txt;
while(txtArea.offsetLeft+txtArea.offsetWidth>buttonArea.offsetLeft){
txt=txt.substr(0,txt.length-1);
txtArea.innerHTML=txt+dots;
if(!txt.length) {
if(dots.length) dots=dots.substr(0,dots.length-1);
else {
txtArea.innerHTML=' ';
break;
}
}
}
}
function btSetWidth(id, newWidth){
if(!dgi(id)) return;
dgi(id).getElementsByTagName('DIV')[0].style.width=newWidth
}
/**
* Progress bar
*/
function progressSetText(id,txt){dgi(id+'_text').innerHTML=txt;}
function progressGetText(id){return dgi(id+'_text').innerHTML}
function progressSetPerc(id,perc){dgi(id+'_inner').style.width=Math.floor(perc)+'%'}
function progressGetPerc(id){var p=dgi(id+'_inner').style.width;return p.substr(0,p.length-1)}
/**
* Tooltip
*/
var tooltipDx=10;
var tooltipDy=10;
var tooltipDelay=500; // Delay before displaying tooltip (ms)
var tooltipNodeId=0; // Node id of currently displayed or to-be-displayed tooltip
var tooltipShown=0; // 1 if tooltip is displayed
var tooltipContentFunction; // cache for tooltip text content function
/**
* CONTEXT MENU
*/
var contextMenuDOC,contextMenuTime,contextMenuObject;
function ContextMenuKD(e){
if(wl.eventKC(e)==27) contextMenuObject.remove();
if(wl.eventKC(e)==13) {
var it=contextMenuObject.items;
for (i=0;i<it.length;i++) if(it[i]['def']) {contextMenuObject.remove();eval(it[i]['action']);return;}
}
}
function ContextMenuItem(ico,caption,action,def){if(ico==='sep') return ico; return {'icon':ico,'caption':caption,'action':action,'def':def}}
/* Context menu item
* items: array of context menu items
* opts: assoc array of options :
button=>node to attach as drop-down menu
align=>'right' or 'left':drop-down menu alignement
*/
function ContextMenu(items,opt){
this.remove=function(e){
if(wl.chrono.microtime()-contextMenuTime<100) return;
disconnect(D,'keydown',ContextMenuKD)
maskHide();
if(dgi('contextMenu')) removeNode(dgi('contextMenu'))
if(contextMenuDOC) D.onclick=contextMenuDOC;
}
if(!items) return;
var x=W.mouseX,y=W.mouseY;
if(x==undefined && !opt['button']) return;
this.items=items;
if(!opt) opt={};
var cm=D.createElement('DIV');
cm.id='contextMenu';
cm.className='dropShadow';
with(cm.style){visibility='hidden';top=0;left=0;}
var o='',it,e;
//o='<table cellpadding=0 cellspacing=0><tr><td>';
o+='<div class="contextMenu" id="contextMenuDiv">';
for(var i=0;i<items.length;i++){
if((it=items[i])=='sep') {
if(i+1<items.length && i>0 && items[i-1]!='sep') o+='<div class="sep"></div>';
}
else if(it['action']){
o+='<a href="javascript:(new ContextMenu()).remove();'+it['action']+'"'+((it['def'])?' style="font-weight:bold"':'')+'>';
o+='<img src="'+(it['icon']||'/gfx/v.gif')+'">'+it['caption']+'</a>';
}
else{
o+='<div class="disabled"><img src="'+(it['icon']||'/gfx/v.gif')+'">'+it['caption']+'</div>';
}
}
o+='</div>';
//o+='</td><td class="sIEr"> </td></tr><tr class="sIEtrb"><td class="sIEb"></td><td class="sIErb"></td></tr></table>';
cm.innerHTML=o;
contextMenuTime=wl.chrono.microtime()
maskShow(true,false,false,this.remove)
D.body.appendChild(cm);
// Extra style
if(opt.style) for(e in opt.style) cm.style[e]=opt['style'][e];
// Set menu position
with(cm.style){
zIndex=maskNode().style.zIndex+1;
if(opt['button']){
y=actualOffsetBottom(opt['button']);
if(opt['align']=='right')
x=actualOffsetRight(opt['button'])-cm.offsetWidth;
else
x=actualOffsetLeft(opt['button']);
}
else{
if(opt['centerFirst']) {x-=12;y-=dgi("contextMenuDiv").firstChild.offsetHeight/2}
x=Math.min(x,dd.getWndW()-cm.offsetWidth)
y=Math.min(y,dd.getWndH()-cm.offsetHeight-20);
}
left=x;top=y;
}
// Egalize all items widths in IE
if(phpBrowser=='ie'){
var sn=cm.firstChild.childNodes,mw=0,e;
for(e in sn) mw=Math.max(mw,sn[e].offsetWidth||0);
if(opt.style && opt.style.width) mw=opt.style.width;
for(e in sn) if(sn[e].nodeType==1) sn[e].style.width=mw+'px';
cm.style.visibility='visible';// IE8 WA
}
if(opt['fade']) fade(cm); else cm.style.visibility='';
connect(D,'keydown',ContextMenuKD,false);
contextMenuObject=this;
}
// Attach a context menu to a given node
function ContextMenuAttach(n,items,opt){
if(typeof(n)=='string') n=dgi(n); if(!n) return;
if(!opt) opt={}; if(opt['button'] && (typeof opt.button)!='object') opt['button']=n;
n.oncontextmenu=function(event){var cm=new ContextMenu(items,opt);return false}
if(opt['leftClick']) n.onclick=function(event){var cm=new ContextMenu(items,opt);return false}
}
// Attach a context menu to a given node
// node: node to attach menu
// items: array of ContextMenuItem
// opt: options (style: assoc array of style properties, button: 1 to attach as button drop-down list to node or otherNode to attach to another DOM node, leftClick to trigger on left click)
function ContextMenuDropDown(node,items,opt){
if(typeof(node)=='string') node=dgi(node); if(!node) return;
if(!opt) opt={};opt['button']=node;
if(!opt['align']) opt['align']='left';
node.onclick=function(event){var cm=new ContextMenu(items,opt);return false}
}
// Attach a context menu to a given node
function ContextMenuDetach(node){
if(typeof(node)=='string') node=dgi(node); if(!node) return;
node.oncontextmenu='';
}
/**
* @desc Mouseover function: entry-point for tooltip
* start timer to dispay tooltip
* @param DOMnode node
* @param string txtContent (optional): content of tooltip. If not set, content is set from tooltipGetContent function
* @param bool noDelay: true to display immediately
*/
var tooltipOnMouseDownFunction,tooltipOnMouseOutFunction; // Temp storage of onmouseout and onmousedown functions, converted to text
function tooltip(node, txtContent, noDelay){
if(!node || (!txtContent && !W.tooltipGetContent) || (W.winMe && !winMe.isActive())) return; // Wrong parameters / config
//if(typeof node="string" && dgi(node)) node=dgi(node); // If passed var is node id instead of id
if(!node.id) node.id='tooltip'+Math.floor(Math.random()*100000);
if(tooltipNodeId==node.id) return; // Wrong parameters / config
// If a tooltip is currently shown, destroy it first (should rarely happend)
//if(tooltipShown) tooltipHide(tooltipNodeId,onmouseoutFunction,'out')
tooltipNodeId=node.id;
tooltipShown=0;
// Memorize onmouseout function (converted to string)
if(node.onmouseout) {
var omo=' '+node.getAttribute('onmouseout'); omo=omo.substr(1);
// IE
if(omo.indexOf('function anonymous')!=-1){omo=omo.substr(23,omo.length-24)}
if(omo.indexOf('tooltipHide')==-1) tooltipOnMouseOutFunction=omo;
}
node.onmouseout=function(e){tooltipHide(node.id,'out')};
// Memorize onmousedown function (converted to string)
if(node.onmousedown) {
var omd=' '+node.getAttribute('onmousedown'); omd=omd.substr(1);
// IE
if(omd.indexOf('function anonymous')!=-1){omd=omd.substr(23,omd.length-24)}
if(omd.indexOf('tooltipHide')==-1) tooltipOnMouseDownFunction=omd;
}
node.onmousedown=function(e){tooltipHide(node.id,'down')}
// Delay-call tooltip show function
tooltipContentFunction=null;
if(!txtContent) txtContent='';
if((typeof txtContent)!='string') {tooltipContentFunction=txtContent; txtContent=''}
W.setTimeout('tooltipShow("'+node.id+'","'+txtContent.replace(/"/g,'\\"')+'",1)',((noDelay)?0:tooltipDelay)); /* \\"*/
}
// Show tooltip
function tooltipShow(nodeId,txtContent,calledByTimer){
var tooltipDiv,node=dgi(nodeId),content;
if(!node || (tooltipNodeId!=nodeId && calledByTimer) || tooltipShown) return; // Error or other tooltip requested since, or tooltip already shown
// Get tooltip content
content=txtContent?txtContent:(tooltipContentFunction)?tooltipContentFunction(node):W.tooltipGetContent(node.id);
// No tooltip content: tooltip should not be displayed
if(!content) {
if(calledByTimer && node.onmouseout!=null) node.onmouseout();
return;
}
// Remove previous tooltip if existing
tooltipDestroy();
// Create container that will host tooltip node
if(!dgi('dragDetach')) {
var ddNode=D.createElement("div");
ddNode.id="dragDetach";
with(ddNode.style){position="absolute";top=0;left=0;zIndex=10000};
D.body.appendChild(ddNode);
}
// Create tooltip DOM node
tooltipDiv=D.createElement("div");
tooltipDiv.id='tooltip';
tooltipDiv.className='tooltip';
tooltipDiv.style.display='none';
tooltipDiv.style.width='400px';
// Fill content
tooltipDiv.innerHTML=content;
dgi('dragDetach').appendChild(tooltipDiv)
// Set draggable
ADD_DHTML('tooltip',1);
dd.elements['tooltip'].maximizeZ();
// Set onmousemove function
node.onmousemove=function(event){tooltipMove(nodeId)};
tooltipShown=1;
dgi('tooltip').style.display='block';
tooltipAdjustToContent();
tooltipMove(nodeId);
}
function tooltipSetContent(h){
if(!dgi('tooltip')) return;
with(dgi('tooltip').style) {visibility='hidden';top=0;left=0}
dgi('tooltip').innerHTML=h;
tooltipAdjustToContent();
tooltipMove();
}
function tooltipAdjustToContent(){
dgi('tooltip').style.width='auto'
dgi('tooltip').style.height=''
}
function tooltipMove(nodeId){
if(!nodeId) nodeId=tooltipNodeId;
if(nodeId!=tooltipNodeId || !tooltipShown || !dgi('tooltip')) return;
var offsetX=(W.pageXOffset?W.pageXOffset:D.body.scrollLeft);
var offsetY=(W.pageYOffset?W.pageYOffset:D.body.scrollTop);
var ttx=mouseX+tooltipDx,tty=mouseY+tooltipDy,tt=dgi('tooltip');
if(tty+tt.offsetHeight>offsetY+D.body.clientHeight) tty=offsetY+D.body.clientHeight-10-tt.offsetHeight;
if(ttx+tt.offsetWidth>offsetX+D.body.clientWidth){
if(tt.offsetWidth > D.body.clientWidth) {
tt.style.whiteSpace='normal';
tt.style.width=(Math.floor(0.9*D.body.clientWidth))+'px';
ttx=(Math.floor(0.05*D.body.clientWidth))+'px';
}
else ttx=mouseX - tooltipDx - tt.offsetWidth;
}
dd.elements['tooltip'].moveTo(Math.max(5,ttx),tty);
}
function tooltipHide(nodeId,mouseXXX){
var node;
if(nodeId==tooltipNodeId) tooltipNodeId=0;
tooltipShown=0;
tooltipDestroy();
if(!(node=dgi(nodeId))) return;
// Restore onmouseout function
if(mouseXXX=='out' && tooltipOnMouseOutFunction) eval(tooltipOnMouseOutFunction.replace(/this/g,'dgi(nodeId)'));
if(mouseXXX=='down' && tooltipOnMouseDownFunction) eval(tooltipOnMouseDownFunction.replace(/this/g,'dgi(nodeId)'));
if(tooltipOnMouseOutFunction) node.onmouseout=tooltipOnMouseOutFunction;
if(tooltipOnMouseDownFunction) node.onmousedown=tooltipOnMouseDownFunction;
tooltipOnMouseDownFunction=0;
tooltipOnMouseOutFunction=0;
node.onmousemove=null;
}
/**
* @desc Remove tooltip DOM node and DHTML element
*/
function tooltipDestroy(){
if(dd.elements['tooltip']) {
dd.elements['tooltip'].hide();
dd.elements['tooltip'].del(1);
}
if(dgi('tooltip')) dgi('tooltip').parentNode.removeChild(dgi('tooltip'));
}
/**
* @desc Fill tooltip with dedicated associative array
*/
function tooltipSetProperties(p){
function tooltipCleanCode(arr){
for(elem in arr) {
if(typeof(arr[elem])=='string'){
if(arr[elem].substr(0,5)=='code:') arr[elem]=arr[elem].substr(5);
}
else tooltipCleanCode(arr[elem]);
}
}
if(!dgi('tooltip')) return;
//tooltipCleanCode(p)
var content='';
// Header
content='<div class="tooltipHeader">'+((p['icon'])?'<img src="'+p['icon']+'" alt="" style="vertical-align:middle;margin-right:0.5em">':'')+((p['header'])?((p['header']['c'])?p['header']['c']:p['header']):p['filename'])+'</div>'
var tURL='';
for(elem in p) if(elem=='thumbnailURL') {tURL=p[elem];break}
// Table for thumbnail + extra data
if(tURL && p['extra']) content+='<table><tr style="vertical-align:top"><td style="padding-right:1em">';
// Thumbnail
if(tURL) {
// If no extra data, center image
if(!p['extra'] && tURL.substr(0,5)!='code:') content+='<center>';
// Image border frame
content+='<div class="tooltipImage"'+((p['thumbnailNoFrame'])?' style="border:0;padding:0;background:transparent"':'')+'>';
// HTML code
if(tURL.substr(0,5)=='code:'){
content+=tURL.substr(5);
}
// URL
else{
content+='<img src="'+loadingIconURL+'" style="position:absolute;margin-left:'+(Math.floor(p['thumbnailURLW']/2)-8)+'px;margin-top:'+(Math.floor(p['thumbnailURLH']/2)-8)+'px">';
content+='<img id="tooltipImg" style="visibility:hidden" alt="" src="'+tURL+'" onload="tooltipImgLoaded()" width="'+p['thumbnailURLW']+'" height="'+p['thumbnailURLH']+'">';
}
content+='</div>';
if(!p['extra'] && tURL.substr(0,5)!='code:') content+='</center>';
}
if(tURL && p['extra']) content+='</td><td>';
// Extra content (right part of thumbnail)
if(p['extra']){
if(p['extra']['extraTitle']){
content+='<b>'+p['extra']['extraTitle']['c']+'</b><br/>';
delete(p['extra']['extraTitle']);
}
content+='<table style="font:inherit;vertical-align:top">';
var nb=0;for(elem in p['extra']) nb++;
var elemNb=0;
for(elem in p['extra']){
if(nb<24 || elemNb%2==0) content+='<tr><td style="padding-right:1em">';
else content+='<td style="padding-right:1em;padding-left:3em">';
if(p['extra'][elem]['v'])
content+='<b>'+p['extra'][elem]['c']+'</b></td><td>'+p['extra'][elem]['v']+'</td>';
else if(p['extra'][elem]['c']) content+='</td><td>'+p['extra'][elem]['c']+'</td>';
else content+='<b>'+elem+'</b></td><td>'+p['extra'][elem]+'</td>';
if(nb<24 || elemNb%2==1) content+='</tr>';
elemNb++;
}
if(nb>23 && elemNb%2==0) content+='</tr>';
content+='</table>';
}
if(tURL && p['extra']) content+='</td></tr></table>';
// Footer
if(p['footer']){
content+='<div class="tooltipFooter">';
if(p['footer']['c']) content+='<b>'+p['footer']['c']+'</b>'+p['footer']['v']; else content+=p['footer'];
p['footer']+='</div>';
}
else if(p['cTime'] && p['mTime']){
content+='<div class="tooltipFooter">';
content+='<div style="width:30em;display:block;height:1px;overflow:hidden"></div>';
content+='<div style="position:absolute;right:1em"><b>'+p['fileSize']['c']+p['sep']+'</b>'+p['fileSize']['v']+'</div>';
content+='<div><b>'+p['cTime']['c']+p['sep']+'</b>'+p['cTime']['v']+'</div>';
content+='<div><b>'+p['mTime']['c']+p['sep']+'</b>'+p['mTime']['v']+'</div>';
content+='</div>';
}
// Set content and fade-in
tooltipSetContent(content);
fade('tooltip',0,1,3);
}
// Thumbnail image loaded
function tooltipImgLoaded(){
if(!dgi("tooltipImg")) return;
if(dgi("tooltipImg").previousSibling) dgi("tooltipImg").parentNode.removeChild(dgi("tooltipImg").previousSibling);
tooltipAdjustToContent();
fade("tooltipImg",0,1,5)
}
/**
* MASK
*/
var maskShown=0;
function maskShow(transparent,doFadeIn,wCurs,onclickF,innerHTML){
var maskDiv, create, maskDivBg;
// Create if inexisting
if(!dgi('maskDiv')){
maskDiv=D.createElement("div");
maskDiv.id='maskDiv';
create=1;
}
// Or retreive
else maskDiv=dgi('maskDiv');
// Set inner HTML (use maskDivBg to prevent opacity to be applied to innerHTML)
maskDiv.innerHTML='<div id="maskDivBg" style="position:absolute;height:100%;width:100%;background:black;border:1px solid red;left:0px;top:0px"> </div>'+((innerHTML)?'<div style="position:relative;top:50%;text-align:center">'+innerHTML+'</div>':'');
// Set onclick and oncontextmenu
if(onclickF) {
maskDiv.onclick=onclickF;
maskDiv.oncontextmenu=function(event){onclickF();return maskRC(event);}
}
else maskDiv.oncontextmenu=maskRC;
with(maskDiv.style){
// Hide
display='none'; position='absolute';
// Cursor
if(!wCurs) curor='pointer';
else if(wCurs===true) cursor='wait';
else cursor=wCurs;
// Position
top='0'; left='0'; margin='0'; padding='0';
width=D.body.scrollWidth;
height=Math.max(D.body.scrollHeight,(W.winMe)?winMe.getInnerHeight():0)-0
zIndex=Math.max(99998,(W.dd && dd.z)?dd.z*1+1:0);
}
if(create) D.body.insertBefore(maskDiv,D.body.firstChild);
maskDivBg=dgi('maskDivBg')
// Color
maskDivBg.style.background='black';
// Opacity
setAlpha(maskDivBg,(transparent)?0.01:0.2);
if(doFadeIn) wl.anim({'item':maskDivBg,'duration':300,'function':function(p,anim){if(p==0) dgi('maskDiv').style.display='';return {'opacity':p*0.2}}}); else maskDiv.style.display='';
//if(doFadeIn) fade(maskDiv,0,0.2,3); else maskDiv.style.display='';
maskShown=1;
}
function maskHide(doFadeOut){
maskShown=0;
if(!dgi('maskDiv')) return;
if(doFadeOut) fade(dgi('maskDiv'),0.2,0,3,'removeNode(dgi("maskDiv"))'); else removeNode(dgi('maskDiv'));
}
function maskNode(){return dgi('maskDiv')};
function ffLoadWA(){D.createElement('div').innerHTML='<img src=\"/gfx/v.gif\">'}
function maskRC(e){if(!e) e=event; if(e.stopPropagation) e.stopPropagation(); else e.cancelBubble=true; return false;}
function maskMoveAbove(n){
if(!maskNode()) return;
if(n.id && W.dd && dd.elements[n.id]) dd.elements[n.id].setZ(Math.max(dd.z,maskNode().style.zIndex*1+1))
else n.style.zIndex=maskNode().style.zIndex*1+1;
}
/**
* dialog box
*
* DialogBox object
* definition: array
* title(opt): box title
* text: main text,
* icon(opt): icon src,
* buttons: array:
* 'ok'(opt): caption of ok button,
* 'cancel'(opt): caption of cancel button
* check(opt): bool, true if default checked, false if default not checked
* checkText(opt): string: checkbox text
*
callBackFunction: string: name of callback function
*/
function dialogBox(definition,callbackFunction){
this.definition=definition;
this.callbackFunction=callbackFunction?callbackFunction:'';
}
dialogBox.prototype.show = function (){
if(this.definition['mask']) maskShow(false,true,false); else maskShow(true);
var boxDiv=D.createElement("div");
boxDiv.id='dialogBox';
boxDiv.className='popup';
boxDiv.style.display='none';
boxDiv.style.width='400px';
boxDiv.style.zIndex=dgi('maskDiv').style.zIndex+1;
iconImage='';
if(this.definition['icon']) iconImage='<img id="dialogBoxIcon" src="'+this.definition['icon']+'" style="vertical-align:middle;margin-right:0.5em">';
// Title
iht='';
if(this.definition['title']) iht+='<div class="popupHeader" id="dialogBoxTitle">'+iconImage+this.definition['title']+'</div>';
else iht+=iconImage;
// main caption
if(this.definition['text']) iht+='<span id="dialogBoxText">'+this.definition['text']+'</text>';
iht+='<br><br><center>';
// text input
if(this.definition['input']!==undefined) iht+='<input type="text" class="textInput" style="width:80%" id="dialogBoxInput" value="'+this.definition['input']+'"><br>';
var nb=0; for(e in this.definition['buttons']) nb++;
// OK button
if(this.definition['buttons']['ok']) iht+=wl.button.create(this.definition['buttons']['ok'],"dialogBoxButtonPressed('ok','"+this.callbackFunction+"')",'/gfx/ok.png','dialogBoxOK')+((nb-->0)?' ':'');
// Cancel button
if(this.definition['buttons']['cancel']) iht+=wl.button.create(this.definition['buttons']['cancel'],"dialogBoxButtonPressed('cancel','"+this.callbackFunction+"')",'/gfx/cancel.png','dialogBoxCancel')+((nb-->0)?' ':'');;
iht+='</center>';
if(this.definition['check']!=undefined) iht+='<input id="dialogBoxCheck" type="checkbox"'+((this.definition['check'])?' checked="checked"':'')+'> ';
if(this.definition['checkText']) iht+='<span id="dialogBoxCheckText" onclick="dgi(\'dialogBoxCheck\').checked=!dgi(\'dialogBoxCheck\').checked">'+this.definition['checkText']+'</span>';
// Fill content
boxDiv.innerHTML=iht;
//D.body.insertBefore(boxDiv,D.body.firstChild);
D.body.appendChild(boxDiv);
// input keystrike monitoring
if(this.definition['input']!==undefined) wl.setKeycodeListener('dialogBoxInput',this.inputKD)
if(this.definition['fade']) fade('dialogBox'); else boxDiv.style.display='';
boxDiv.style.top=(winMe.getInnerHeight()-boxDiv.offsetHeight)/2;
boxDiv.style.left=(winMe.getInnerWidth()-boxDiv.offsetWidth)/2;
}
dialogBox.prototype.inputKD = function (kc){
if(kc==27 && dgi('dialogBoxCancel')) eval(dgi('dialogBoxCancel').href)
if(kc==13 && dgi('dialogBoxOK')) eval(dgi('dialogBoxOK').href)
}
dialogBox.prototype.hide = function (){
dgi('dialogBox').parentNode.removeChild(dgi('dialogBox'));
maskHide();
}
dialogBox.prototype.item=function(name){
if(name=='ok') return dgi('dialogBoxOK');
if(name=='cancel') return dgi('dialogBoxCancel');
if(name=='input') return dgi('dialogBoxInput');
if(name=='check') return dgi('dialogBoxCheck');
if(name=='title') return dgi('dialogBoxTitle');
if(name=='text') return dgi('dialogBoxText');
if(name=='checkText') return dgi('dialogBoxCheckText');
if(name=='icon') return dgi('dialogBoxIcon');
}
function dialogBoxButtonPressed(button,callback){
var result={'button':button};
if(dgi('dialogBoxCheck')) result['check']=dgi('dialogBoxCheck').checked;
if(dgi('dialogBoxInput')) result['input']=dgi('dialogBoxInput').value;
if((!callback) || window[callback](result)==undefined){
dgi('dialogBox').parentNode.removeChild(dgi('dialogBox'));
maskHide();
}
}
// Async submit comForm
function asyncSubmit(forceSending){
var dcf=D.comForm;
data="";
for(var i=1;i<6;i++) if(dcf['data'+i].value.length>0) data+=((i>1)?"&":"")+"data"+i+"="+encodeURIComponent(dcf['data'+i].value);
return sendData(data,dcf.action,forceSending);
}
// Async submit a form
function asyncSubmitForm(formId,forceSending){
if(!dgi(formId)) return false;
var frm=dgi(formId);
var elt;
data='';
for(var o=0;o<frm.getElementsByTagName("input").length;o++) {
elt=frm.getElementsByTagName("input")[o];
if(elt.name.length){
if((elt.type!='radio' && elt.type!='checkbox') || elt.checked){
if(data.length>0) data+='&';
data+=elt.name+'='+encodeURIComponent(elt.value);
}
}
}
for(var o=0;o<frm.getElementsByTagName("select").length;o++) {
elt=frm.getElementsByTagName("select")[o];
if(data.length>0) data+='&';
data+=elt.name+'='+encodeURIComponent(elt.value);
}
return sendData(data,frm.action,forceSending);
}
/*********************************************************************************************
* wl Object
*********************************************************************************************/
function wJSLib(){
var me=this;
this.KDS={};
/**
* Sync Post data without a pre-created form
*/
this.postData = function (data,URL){
var f=D.createElement('FORM'), h='';
if(data) for(var e in data) h+='<input type="text" name="'+e+'" value="'+data[e]+'">';
f.style.display="none";
f.enctype="multipart/form-data";
f.method="POST";
if(URL) f.target=URL;
f.innerHTML=h;
D.appendChild(f);
f.submit();
}
/**
* Go to URL
*/
this.goURL=function(URL){
var tURL=D.location.href;
// If URL not provided, set current URL (remove hash as it prevents page from reloading)
if(!URL){URL=tURL;if(URL.indexOf('#')>0) URL=URL.substr(0,URL.indexOf('#'));}
// If only GET parameters passed, reuse current URL
else if(URL.substr(0,1)=='?'){
if(tURL.indexOf('?')>0) tURL=tURL.substr(0,tURL.indexOf('?'));
URL=tURL+URL;
}
D.location.href=URL;
}
/**
* Pack an associative array into an URL-proof string
*/
this.arrayPack=function(o){
if(typeof(o)!='object') return '"'+encodeURIComponent(o)+'"';
var s='{',e,nb=0;
for(e in o) {
s+=((nb++==0)?'':',')+'"'+encodeURIComponent(e)+'"%3A'; // %3A=:
if(typeof(o[e])=='object') s+=this.arrayPack(o[e]);
else s+='"'+encodeURIComponent(o[e].toString().replace(/\"/g,'\\"'))+'"';
}
return s+'}';
}
/**
* fade item's opacity to given alpha value
* i: item or item's id
* a (0-1): target alpha
* nbSteps: number of steps to reach target alpha
*/
this.fadeItems={}
this.fadeTo = function (i,a,nbSteps){
if(typeof(i)=='object'){if(i.id) i=i.id; else i=i.id='id'+Math.floor(999999*Math.random());}
if(wl.fadeItems[i]===a) return;
var n=dgi(i),ca=n.style.opacity;
if(n.style.display=='none'||n.style.visibility=='hidden') ca=0;
else if(ca===undefined || ca==='') {
if(ca=n.style.filter) {
ca=(ca.substring(ca.indexOf('ty=')+3,ca.indexOf(')')))/100;
}
else ca=1;
}
if(nbSteps==undefined) nbSteps=Math.floor(Math.abs(ca-a)*10);
wl.fadeItems[i]=a;
fade(i,ca*1.0,a*1.0,nbSteps)
}
/**
* Animation function
* @param p: animation parameters
* .duration: animation duration, in ms (default 500ms)
* .item: dom node to animate
* or .items: array of {'item':, 'function':} (if .items is passed, .function parameter is only passed in items array)
* .function: animation function, taking as 3 parameters animation step (0-1), animated node, animation data, and returning an associative array of style properties applyed to node.
* Note: parameters can be passed to animation function by passing extra parameters to this (anim) function
* .callbackStep: function called at every step, passing animation data as parameter
* .callbackComplete: function called when anim completed, passing animation data as parameter
* .reverse: set to true to animate in reverse side
*/
this.anim = function(p){
var prop,e,i,it,s;
p.time=wl.chrono.microtime();
// Init animation
if(!p.timeStart) p.timeStart=p.time;
p.dt=(p.prevTime!==undefined)?p.time-p.prevTime:0;
p.prevTime=p.time;
if(!p.duration) p.duration=500;
p.step=Math.min(1,(p.time-p.timeStart)/p.duration);
if(p.reverse) p.step=1-p.step;
// Single item in animation
if(p.item) {
prop=p['function'](p.step,p)
s=p.item.style;
for(e in prop) {
if(e=='opacity') setAlpha(p.item,prop[e]); else s[e]=prop[e];
}
}
// Multiple items in animation
if(p.items){
for(i=0;i<p.items.length;i++){
it=p.items[i];
s=it.item.style;
prop=it['function'](p.step,it)
for(e in prop) {
if(e=='opacity') setAlpha(it,prop[e]); else s[e]=prop[e];
}
}
}
// Call animation step callback if set
if(p.callbackStep) {if(typeof p.callbackStep=='string') eval(p.callbackStep); else p.callbackStep(p)}
// Timeout to next animation step
if((p.reverse && p.step>0) || (!p.reverse && p.step<1)) setTimeout(function(){wl.anim(p)},1);
// Anim completed
else {
// Call callback if set
if(p.callbackComplete) {if(typeof p.callbackComplete=='string') eval(p.callbackComplete); else p.callbackComplete(p)}
}
}
/**
* Common unfold animation profile function
* @param p: unfold percentage (0-1)
*/
this.animFunctionUnfold1 = function(p){
if(p<0.5) w=Math.min(1,Math.pow(p*2,2)); else w=1-Math.abs(Math.sin(Math.PI*(p-0.5)*2)*Math.exp(-4*p));
return w;
}
/**
* Elastic unfold animation profile function
* @param p: unfold percentage (0-1)
*/
this.animFunctionUnfold2 = function(p,anim){
var i,x=anim.animX,v=anim.animV,dt=2,nx,nb;
var m=1,r1=8,r2=10,l=600;
// Init speed & position
if(x===undefined){
v=0; x=1;
// Special: windows animation: integrate animation amplitude into elastic computing
if(anim.extraParams){
x=Math.abs(anim.extraParams.destW-anim.extraParams.startW)/1000;
if(isNaN(x)) x=1;
}
}
nb=Math.ceil(anim.dt/dt);
dt/=1000;
// Compute new speed & position
if(p==1) x=0;
else for(i=0;i<nb;i++){
v+=(-x*l-r1*v-r2*v*Math.abs(v))*dt;
x+=v*dt
}
// Store speed & position
anim.animX=x; anim.animV=v;
return 1-x;
}
/**
* Common unfold animation profile function (small bounce)
* @param p: unfold percentage (0-1)
*/
this.animFunctionFold1 = function(p,anim){
if(p<0.5) w=1-Math.min(1,Math.pow(2*p,2)); else w=-0.7*(2*p*p-3*p+1);
return w;
}
/**
* Negative exponential unfold animation profile function
* @param p: unfold percentage (0->1)
*/
this.animFunctionFold2 = function(p,anim){
var f=-9,w=(Math.exp(f*p) - Math.exp(f))/(1-Math.exp(f));
if(p==1) w=0;
return Math.max(w,0);
}
/**
* collapse/unfold nodes
*/
this.COLLAPSE_DURATION=700; // Time of a fold / unfold animation (ms)
this.nodeCollapseInProgress={}; // Assoc. array of collapse animations in progress
// Hide / show draggable items contained into collapasable frame
this.toggleContainedDragItems = function(item,action){
var o,i;
if(!W.dd || !dd.elements || !dd.elements.length) return;
for(i=0;i<item.childNodes.length;i++){
if(item.childNodes[i].attributes && item.childNodes[i].attributes["id"]) {
for(o=0;o<dd.elements.length;o++){
if(dd.elements[o].name==item.childNodes[i].attributes["id"].value) {
if(action=='hide') dd.elements[o].hide(); else dd.elements[o].show();
}
}
}
if(item.childNodes[i].hasChildNodes) wl.toggleContainedDragItems(item.childNodes[i],action);
}
}
// True if frame is collapsed
this.isCollapsed = function(id){
var s=dgi(id).style;
return (s.display=='none' || s.height=="0px" || s.height=="1px")
}
/**
* Animation function for vertical fold/unfold anims
* @param p: anim percentage 0-1
* @param n: animated node
* @param anim: anim parameters (see wl.anim function). Includes tHeight var indicating block unfolded height
*/
this.nodeCollapseAnim = function(p,anim){
var h=Math.floor(anim.tHeight*((anim.reverse)?wl.animFunctionFold1(1-p):wl.animFunctionUnfold1(p,anim)));
if(phpBrowser=='ie' && h==0) h=1;// 0px height causes problems under IE
return {'height':h+'px'}
}
/**
* Toggle collapse state of a node, and animate
* @param id: id of node
* @param phpVarName: if set, name of php var that must be async updated to set to true if collapsed, false if unfolded
* @param jsCallbackFunction: id of node
*/
this.nodeCollapseToggle = function(id, phpVarName, jsCallbackFunction){
if(wl.nodeCollapseInProgress[id]) return;
wl.nodeCollapseInProgress[id]=1;
if(wl.isCollapsed(id))
wl.nodeCollapseUnfold(id, phpVarName, jsCallbackFunction)
else
wl.nodeCollapseFold(id, phpVarName, jsCallbackFunction)
}
/**
* Unfold a node
* See nodeCollapseToggle for parameters
*/
this.nodeCollapseUnfold = function(id, phpVarName, jsCallbackFunction){
var s,n,tHeight;
if(!(n=dgi(id))) return;
s=n.style;
// transparently unfold div to compute inner height
s.visibility='hidden';s.position='absolute';s.height='';s.display='';
tHeight=n.offsetHeight;
s.overflow='hidden';s.height='1px';s.position='static';s.visibility='visible';
// Anim start callback (backward compatibility)
if(jsCallbackFunction && typeof jsCallbackFunction=='string') eval(jsCallbackFunction+'("'+id+'","startUnfold")');
// Change toggle button icon
if(dgi(id+'BtMinus') && dgi(id+'BtPlus')) {dgi(id+'BtMinus').style.display='inline';dgi(id+'BtPlus').style.display='none';}
// Hide / show draggable items contained into collapasable frame
wl.toggleContainedDragItems(n,'show');
// Update server-side var
if(phpVarName) sendData(phpVarName+"=true",PHP_SELF,false);
// Start animation
wl.anim({'item':n,
'duration':wl.COLLAPSE_DURATION,
'function':wl.nodeCollapseAnim,
'tHeight':tHeight,
'callbackStep':jsCallbackFunction,
'callbackComplete':function(anim){
s=anim.item.style; s.position=''; s.height=''; s.overflow=''; s.margin=''; s.padding='';
if(jsCallbackFunction) eval(jsCallbackFunction+'("'+id+'","doneUnfold")');
if(W.onCollapseFunction) onCollapseFunction(id,"doneUnfold");
if(W.dd) dd.recalc();
wl.nodeCollapseInProgress[id]=0;
}
});
}
/**
* Fold a node
* See nodeCollapseToggle for parameters
*/
this.nodeCollapseFold = function(id, phpVarName, jsCallbackFunction){
var s,n,tHeight;
if(!(n=dgi(id))) return;
s=n.style;
tHeight=n.offsetHeight;
s.overflow='hidden';
// Anim start callback (backward compatibility)
if(jsCallbackFunction && typeof jsCallbackFunction=='string') eval(jsCallbackFunction+'("'+id+'","startFold")');
// Change toggle button icon
if(dgi(id+'BtMinus') && dgi(id+'BtPlus')) {dgi(id+'BtMinus').style.display='none'; dgi(id+'BtPlus').style.display='inline';}
// Update server-side var
if(phpVarName) sendData(phpVarName+"=false",PHP_SELF,false);
// Start animation
wl.anim({'item':dgi(id),
'duration':wl.COLLAPSE_DURATION,
'function':wl.nodeCollapseAnim,
'reverse':1,
'tHeight':tHeight,
'callbackStep':jsCallbackFunction,
'callbackComplete':function(anim){
s=anim.item.style;s.height=((phpBrowser=='ie')?1:0)+'px';s.visibility="hidden";s.margin=0;s.padding=0;
wl.toggleContainedDragItems(dgi(id),'hide');
if(jsCallbackFunction) eval(jsCallbackFunction+'("'+id+'","doneFold")');
if(W.onCollapseFunction) onCollapseFunction(id,"doneFold");
if(W.dd) dd.recalc();
wl.nodeCollapseInProgress[id]=0;
}
})
}
/**
* Scroll divs
*/
function asd(){this.scrolling=0;this.divList=[]}
asd.prototype.add = function (item){
this.divList.push(item);
}
asd.prototype.check = function (){
if(!dd.obj) return;
var it;
for(var i=0;i<this.divList.length;i++){
it=this.divList[i];
if(dd.obj.y>actualOffsetTop(it) && dd.obj.y<actualOffsetTop(it)+2*dd.obj.h && dd.obj.x>actualOffsetLeft(it) && dd.obj.x+dd.obj.w<actualOffsetRight(it)) this.scroll("up",it);
if(dd.obj.y>actualOffsetBottom(it)-2*dd.obj.h && dd.obj.y+dd.obj.h<actualOffsetBottom(it) && dd.obj.x>actualOffsetLeft(it) && dd.obj.x+dd.obj.w<actualOffsetRight(it)) this.scroll("down",it);
}
}
asd.prototype.scroll = function (dir,item){
if(this.scrolling) return;
this.scrolling=1;
if(dir=='up') item.scrollTop-=20; else item.scrollTop+=20;
W.setTimeout('wl.autoScrollDivs.done()',10);
}
asd.prototype.done = function (){this.scrolling=0;this.check()}
this.autoScrollDivs=new asd();
/**
* Debug functions
*/
this.dbgw=function(txt,lineBreak){if(parent && parent.winDebug) parent.winDebug(txt,lineBreak); else winDebug(txt,lineBreak)}
this.dbgServer=function(txt,toFile){sendData('toFile='+toFile+'&dbgServer='+encodeURIComponent(txt),'/servDbg.php')}
// Chrono
function chrono(){this.v=0};
chrono.prototype.microtime=function (){return (new Date()).getTime()}
chrono.prototype.start=function (){this.chrono=this.microtime()}
chrono.prototype.get=function (){return this.microtime()-this.chrono}
this.chrono=new chrono();
/**
* Misc functions
*/
/*
* Animations: remove actual processing time to animation timeout value
*/
this.adaptedTimeoutValueStart = function(){this.aTVSC=wl.chrono.microtime()}
this.adaptedTimeoutValue = function(t){return Math.max(0,t-wl.chrono.microtime()+this.aTVSC)}
// Get flash player from id
this.getFlashPlayer = function (id){
if(navigator.appName.indexOf("Microsoft") != -1) return window[id]; else return document[id];
}
/**
* Cross-browser (ie. works in IE) setTimeout function
*/
this.setTimeout = function(){
var a = arguments;
if(a.length<3) return setTimeout(a[0],a[1]);
return setTimeout(function(){a[0](a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9])},a[1]);
}
/**
* Cross-browser (ie. works in IE) setTimeout function
*/
this.setInterval = function(){
var a = arguments;
if(a.length<3) return setInterval(a[0],a[1]);
return setInterval(function(){a[0](a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9])},a[1]);
}
// Add a function calling callback on key pressed, with keycode value as argument, pass null as callback to remove
// evt: 'onkeyup' or 'onkeydown'
this.setKeycodeListener = function (n,callback,evt){
if(typeof n=='string') n=dgi(n);
if(!n) return;
if(evt='onkeyup'){
n.onkeyup=n.onkeydown;
n.onkeyup=(callback)?wl.eventToKeycode:null;
}
else{
n.onkeydowntmp=n.onkeydown;
n.onkeydown=(callback)?wl.eventToKeycode:null;
}
n.keycodeListenerCallback=callback;
}
this.removeKeycodeListener = function (item){
item.onkeydown=(item.onkeydowntmp)?item.onkeydowntmp:function(e){};
}
this.eventToKeycode=function(e){
var kc=wl.eventKC(e),srcT,t;
if(e){ // Gecko
t=e.target
}
else if(W.event){ // IE & Opera
t=W.event.srcElement
e=W.event
}
srcT=t;
while(!t.keycodeListenerCallback && t.parentNode && t!=t.parentNode) t=t.parentNode
t.keycodeListenerCallback(kc,srcT,e)
}
// Return keycode from event
this.eventKC=function(e){return (e&&e.which)?e.which:(W.event?event.keyCode:0);}
// Key Down handler
this.KDHandler=function(e){kc=wl.eventKC(e);var t=(e.target)?e.target:e.srcElement; for(i in wl.KDS[t]) if(i==kc) eval(wl.KDS[t][i])}
this.KDHandlerD=function(e){kc=wl.eventKC(e); for(var i in wl.KDS[D]) if(i==kc) eval(wl.KDS[D][i])}
this.setKDHandler=function (n,kds){
wl.KDS[n]=kds;
if(n==D) n.attachEvent?n.attachEvent('onkeydown',wl.KDHandlerD):n.addEventListener('keydown',wl.KDHandlerD,false);
else n.attachEvent?n.attachEvent('onkeydown',wl.KDHandler):n.addEventListener('keydown',wl.KDHandler,false);
}
// Stop event propagation
this.stopPropagation=function(event){
try{event.stopPropagation()}catch(er){event.cancelBubble = true}
}
// Prevent backspace key to go back to previous page (instead try goBack function)
this.blockBackspace=function(){
D.onkeydown=function(e){
if(!e) e=W.event;
if(wl.eventKC(e)!==8) return true;
var t=e.target||e.srcElement;if(t&&t.tagName!='INPUT'&&t.tagName!='TEXTARREA') {
if(W.goBack) setTimeout('goBack()',5);
return false
}
}
}
// Add 2 1-level objects, return result
this.objectsAdd=function(a,b){
for(var e in b) a[e]=b[e];
return a;
}
/**
* Buttons (button CSS class, outButton PHP function)
*/
function button(){}
this.button=new button();
// HTML code for creating a button
button.prototype.create = function (caption,script,icon,id,disabled){
var iht='<a ';
if(id) iht+='id="'+id+'" ';
if(caption) iht+='title="'+caption+'" ';
if(disabled) iht+='class="buttonDisabled" href="javascript://'+script+'">';
else iht+='class="button" href="javascript:'+script+'">';
iht+='<i> </i><b>';
if(icon) {
iht+='<img alt="" src="'+icon+'" onclick="'+((disabled)?'//':'').script+'" ';
if(caption && caption.length>0) iht+='style="margin-right:0.4em"';
iht+='>';
}
else
iht+='<img alt="" src="/gfx/v.gif">';
iht+='<span></span><span>'+caption.replace(/ /g,' ')+'</span></b><u> </u></a>';
return iht;
}
// Is button enabled ?
button.prototype.isEnabled = function (bt){
if(typeof bt=='string') bt=dgi(bt);
if(!bt) return false;
return bt.className=='button'
}
// Enable button
button.prototype.enable = function (bt,en){
if(en===false) return wl.button.disable(bt);
if(typeof bt=='string') bt=dgi(bt);
if(!bt || bt.className=='button') return;
bt.className='button';
var hr=bt.getAttribute("href");
if(hr.substr(11,3)=='//#') bt.href=hr.substr(14); // if href is like javascript://#, turn it into an URL
else bt.href='javascript:'+hr.substr(13);// if href is like javascript://, turn it into a javascript action
var img=bt.firstChild.nextSibling.firstChild;
// remove // from onclick property
if(img.hasAttribute && img.hasAttribute("onclick")){txt=img.getAttribute("onclick")+'';img.onclick=txt.substr(2);}
else if(img.onclick) {img.onclick=function (){eval(img.parentNode.parentNode.href.replace(/\/\//,'')) }} // IE
}
// Disable button
button.prototype.disable = function (bt){
if(typeof bt=='string') bt=dgi(bt);
if(!bt || bt.className=='buttonDisabled') return;
bt.className='buttonDisabled';
var hr=bt.href;
if(hr.substr(0,11)=='javascript:') bt.href='javascript://'+hr.substr(11);
else bt.href='javascript://#'+hr;
var img=bt.firstChild.nextSibling.firstChild;
if(img.onclick) img.onclick='//'+img.onclick;
if(img.hasAttribute){if(img.hasAttribute("onclick")) {img.onclick='//'+img.getAttribute("onclick")}}
else if(img.onclick) img.onclick='//'+img.onclick;
}
// Set icon
button.prototype.setIcon = function (bt,nSrc){
if(typeof bt=='string') bt=dgi(bt);
if(!bt) return;
var img=bt.firstChild.nextSibling.firstChild;
if(img.tagName=='IMG') img.src=nSrc;
else img.style.filter=img.style.filter.substr(0,img.style.filter.indexOf("src='")+5)+nSrc+"')";
}
// Set caption/label
button.prototype.setCaption = function (bt,txt){
if(typeof bt=='string') bt=dgi(bt);
if(!bt) return;
if(bt.firstChild.nextSibling.firstChild.nextSibling.nextSibling)
bt.firstChild.nextSibling.firstChild.nextSibling.nextSibling.innerHTML=txt;
else
bt.firstChild.nextSibling.firstChild.nextSibling.innerHTML=txt;
}
// Set function
button.prototype.setFunction= function (bt,funcTxt){
if(typeof bt=='string') bt=dgi(bt); if(!bt) return;
if(bt.className=='button'){
bt.href='javascript:'+funcTxt;
var img=bt.firstChild.nextSibling.firstChild;
if(img) img.onclick=function(){eval(funcTxt)}
}
}
/**
* Block items functions
*/
function bI (id){if(typeof id == 'string') this.n=dgi(id); else this.n=id;}
bI.prototype.enable=function(doEnable){if(doEnable || doEnable==undefined) $(this.n).e.className().remove('biDisabled'); else $(this.n).e.className().add('biDisabled')}
bI.prototype.over=function(){if(this.n.className.indexOf("biDisabled")==-1) $(this.n).e.className().add('biOver')}
bI.prototype.out=function(){$(this.n).e.className().remove('biOver')}
bI.prototype.select=function(doSelect,check){
var na,e;
if($(this.n).e.className().has('biDisabled')) return;
if(doSelect||doSelect==undefined) {
// Set item as selected (or remove selection if already selected & checkbox
if(check && $(this.n).e.className().has('biSel')) $(this.n).e.className().remove('biSel'); else $(this.n).e.className().add('biSel');
// unselect other blockitems
if((na=this.n.getAttribute('name')) && !check) {
var items=D.getElementsByTagName('FIELDSET');
for(e in items) if(items[e] && items[e].getAttribute && items[e].getAttribute('name')==na && items[e]!=this.n) wl.blockItem(items[e]).select(0);
}
}
else $(this.n).e.className().remove('biSel')
}
bI.prototype.selected=function(){return this.n.className.indexOf("biSel")!=-1}
bI.prototype.enabled=function(){return this.n.className.indexOf("biDisabled")==-1}
this.blockItem=function(id){return new bI(id)}
// Block items group
function bIG(name){this.n=name}
bIG.prototype.getItems=function(){
var r=[],l=D.getElementsByTagName('FIELDSET');
for(e in l) if(l[e] && l[e].getAttribute && l[e].getAttribute('name')==this.n) r.push(new wl.blockItem(l[e]));
return r;
}
// Return an array of id of selected item(s)
bIG.prototype.getSelectedItemsIds=function(){
var s=Array(),items=D.getElementsByTagName('FIELDSET'),e,i=0;
for(e in items) if(items[e] && items[e].getAttribute && items[e].getAttribute('name')==this.n && wl.blockItem(items[e]).selected()) s[i++]=items[e].id;
return s;
}
this.blockItemGroup=function(name){return new bIG(name)}
/**
* UI communication
* Send command to UI
* If returnDataName set, fill result into input named so, and fire onkeyup event
* Else if callback set, call callback function with return value
*/
this.UICommandCallbackF=0;
this.UICommandCallbackN=0;
this.UICommandCallback = function (e){
if((typeof wl.UICommandCallbackF)=='string') eval(wl.UICommandCallbackF+'(wl.UICommandCallbackN.value)');
else wl.UICommandCallbackF(wl.UICommandCallbackN.value);
}
this.UICommand=function (command, returnDataName, callback){
var n;
if(callback && !returnDataName){
n=dgi("uicommandcb")
if(!n){
n=D.createElement('INPUT');
n.id='uicommandcb';
n.name='uicommandcb';
returnDataName='uicommandcb';
with(n.style){position='absolute';top=0;display='none';}
D.body.appendChild(n);
}
wl.UICommandCallbackF=callback
wl.UICommandCallbackN=n
n.onkeyup=this.UICommandCallback
returnDataName='uicommandcb';
}
top.location.href="UI:"+command+((returnDataName)?':'+returnDataName:'');
}
// Open a web popup in application, and callback cb function (or function name) with return string
this.UIWebPopup=function(url,cb){
wl.UICommand('webPopup:'+url,false,cb);
}
// web popup response return
this.UIWebPopupReturn=function(data){
if(isApp) wl.UICommand('close:'+data);
}
// Set response of UI web popup when closed by user with esc or window closed
this.UIWebPopupSetCancelReturnArgs=function(r){
wl.UICommand('setCancelReturnArgs:'+r);
}
/**
* Show help
*/
this.showHelp=function(capt){
var a=W,b=W;while(a.parent && a!=a.parent) {
a=a.parent;
try{if(a.dd) b=a} catch(e){break;}
}
b.sendData('hId='+capt,'/help.php');
}
// Copy text to clipboard (IE)
this.clipboardCopy=function(id){
with(dgi(id).createTextRange()){
execCommand("RemoveFormat");
execCommand("Copy");
}
}
/**
* Fade any CSS p from current to "end" state
* @param id: id of node
* @param p: style property to fade
* @param end: final state (no unit set, use current state's)
* @param type: 'linear' or 'exponential' (opt:linear)
* @param nbSteps: 'linear' or 'exponential' (opt:imgFadeSteps)
* @param cb: callback on completition (opt:no)
*/
this.fadeStyle = function (id, p, end, type, nbSteps, cb){
var isStyle=(p!='scrollTop'&&p!='scrollLeft');
var n=dgi(id),s=(isStyle)?n.style:n;val=''+s[p],unit='',v=0;
if(val==''){
if(p=='height') val=''+n.offsetHeight+'px';
if(p=='width') val=''+n.offsetWidth+'px';
}
if(val.substr(val.length-1)=='%') unit='%';
if(val.substr(val.length-2)=='px') unit='px';
v=1*val.substr(0,val.length-unit.length);
// Set number of steps
if(nbSteps==undefined) {if(v==end) nbSteps=1; else nbSteps=10;}
if(nbSteps<=1) v=end;
else {if(type=='exponential') v=(2*v+end)/3; else v+=(end*1-v*1)/nbSteps;}
if(p=='alpha') setAlpha(n,v);
else {
if(Math.floor(v)==0 && (p=='height'||p=='width')) s.display='none'; // IE WA: height/width 0px doesn't work
else s[p]=''+Math.floor(v)+unit;
}
if(nbSteps<=1){if(cb && cb!=='undefined') eval(cb); return;}
W.setTimeout('wl.fadeStyle("'+id+'", "'+p+'", '+end+', "'+type+'", '+(nbSteps-1)+', "'+cb+'")',((phpBrowser=='gecko')?50:5));
}
/**
* ext/img functions
*/
this.extImageSrc=function (filename,w,h,opt){
if(!opt) opt={};
return '/img/w.'+w+'/h.'+h+'/cache.'+((opt['noCache'])?0:1)+'/resId.'+resId+'/file.'+encodeURIComponent(filename).replace(/%2F/g,"/");
}
/**
* Preload an image into browser cache
* @param src: image src
* @param src: onloadCallback: function called on image load
*/
this.imgPreload=function(src,onloadCallback,onerrorCallback){
var i=new Image()
if(onloadCallback) i.onload=onloadCallback;
if(onerrorCallback) i.onerror=onerrorCallback;
i.src=src;
}
/**
* Asynchronous requests
*/
this.AsynchronousRequest = function (){
this.seq=1; // Sequential number of requests
this.reqs={}; // Array of id=>requests
this.method='POST'; // Default requests method (allways GET, may be set tp POST);
/**
* Main async request function
* d: data, url encoded or associative array
* url: target URL, current if not set
* mode: 0=immediate, 1=queue if other requests in progress
* Return: request id, or 0 if failure
*/
this.send = function (d,url,mode){
var r,dd='';
if(d.fileSize) this.method = 'FILE';
// If data is a file,don't do anything now
if(d.fileSize){
dd=d;
}
// Convert args array to URL encoded format
else {
if(typeof(d)=='object'){for(e in d) dd+='&'+e+'='+encodeURIComponent(d[e])} else dd=d;
dd=dd.replace(/\+/g,"$weezoPlus$")+"&asyncRequest=1"+((W.resId)?"&resId="+resId:"");
if(dd.substr(0,1)=='&') dd=dd.substr(1);
}
// Fill URL
if(!url) url=D.location.href;
// Set mode
if(mode!=1) mode=0;
// Create request
if(!(r=new this.request(dd,url,mode))) return 0;
// Store in requests array
wl.asr.reqs[r.id]=r;
// Send or let in queue
if(!mode || count(wl.asr.reqs)==1) r.send();
return r.id;
}
/**
* Cancel all requests
*/
this.cancelAll = function (){
var limit=0;
while(count(wl.asr.reqs) && limit++<5) for(e in wl.asr.reqs) {
if(wl.asr.reqs[e] && wl.asr.reqs[e].state==2) try{wl.asr.reqs[e].abort()} catch(e){}
delete(wl.asr.reqs[e])
};
}
/**
* Cancel single request (also called on request completed)
* req: request or request id
*/
this.cancel = function (req){
var id;
if(typeof req!='object') id=req; else id=req.id;
if(wl.asr.reqs[id]){
// Stop if still in progress
if(wl.asr.reqs[id].state==2) try{wl.asr.reqs[id].abort()} catch(e){}
// Remove from list
try{delete(wl.asr.reqs[id])} catch(e){}
}
// Launch next pending request
for(var e in wl.asr.reqs) if(wl.asr.reqs[e].state==1) return wl.asr.reqs[e].send();
}
/**
* Return request item from id
*/
this.getRequest = function (id){return wl.asr.reqs[id];}
/**
* Request object. See .send() for args (except d must be url-encoded)
*/
this.request = function (d,url,mode){
var rid=wl.asr.seq++;
this.data=d; // Request data (url-encoded query string)
this.url=url;
this.id=rid; // Request id, index of ASR.reqs array
this.state=mode; // Request state (0, pending, 1 in queue, 2 in progress, 3 completed (process in progress)
this.RTReadBytes=0;
this.RTProcessed=0;
this.method='GET';
// Detect data is a file => switch to file upload mode
if(d.fileSize) this.method = 'FILE';
// All browsers except IE6-
if(W.XMLHttpRequest) this.xhr = new XMLHttpRequest();
// IE6- or IE7+ with disabled native XMLHTTP request
else if (W.ActiveXObject) {
try{this.xhr = new ActiveXObject("MSXML2.XMLHTTP.6.0")}
catch(e){
try{this.xhr = new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){alert('XMLHttpRequest error: Internet Explorer asynchronous request and ActiveX disabled');return false}
}
}
try{this.xhr.id=rid}catch(e){} // Also store id in XMLHttpRequest object
/**
* Do send data
*/
this.send=function(async){
if(async==undefined) async=true;
// GET request (only if query string not too long)
if(wl.asr.method=="GET" && d.length<1950) {
// Open
if(url.indexOf('?')!=-1) this.xhr.open("GET", url+'&'+d,async); else this.xhr.open("GET", url+'?'+d, async);
this.method='GET';
// Send
this.xhr.send(null);
}
// POST / FILE request
else {
// Open
this.xhr.open("POST", this.url, async);
// Set headers
if(wl.asr.method=='POST')
this.xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
// file upload
else{
this.xhr.setRequestHeader('Content-Type', 'multipart/form-data');
this.xhr.setRequestHeader('X-File-Name', this.data.fileName);
this.xhr.setRequestHeader('X-File-Size', this.data.fileSize);
}
// Send
this.xhr.send(this.data);
}
this.state=2; // Set in progress
this.data=''; // Clear request args as they are not needed any longer
// Show request in progress
wl.asr.setRequestIndicator(1)
// Opera WA: use timer to monitor reception
if(phpBrowser=='opera') {
this.RTInt=W.setTimeout(this.xhr.onreadystatechange,100,this.id);
this.TO=1;
}
}
// Set callback
this.xhr.onreadystatechange = function (id) {
// Callback seems sometimes to be called after window is called, throwing an error on wl
if(!window.wl) return;
// this is xhr (FF)
if(this && this.id) rid=this.id;
// Called by timer (opera RT WA)
else if(id && typeof(id)!='object') rid=id;
// Retreive request
var r,xhr,rt;
r=wl.asr.reqs[rid];
if(!r||!r.xhr) return; // Not in list anymore => canceled request
xhr=r.xhr;
if(r.TO) r.RTInt=W.setTimeout(r.xhr.onreadystatechange,100,id); // Restart timeout
try{rt=xhr.responseText} catch(e){return} // IE Workaround on uncompleted requests
// Real-time processing
var rl=rt.length,s,e,c,geckoBuffer='';
if(rl==r.RTReadBytes && xhr.readyState!=4) return;
r.RTReadBytes=rl;
while((e=rt.indexOf('</JSRT>',r.RTProcessed))>r.RTProcessed){
s=rt.indexOf('<JSRT>',r.RTProcessed); c=rt.substring(s+6,e).replace(/</g,'<');
// Process extracted js code
if(W.PHPDebug) {try{eval(c)} catch(e){alert('RT Async err: '+e+"\n"+c)}} else eval(c);
r.RTProcessed=e+7;
}
if(xhr.readyState!=4) return;
// Request completed: process
wl.asr.setRequestIndicator(0);
r.state=3;
// Failed request
if(xhr.status!=200 || !xhr.responseText.length) return r.cancel();
// Process response
var xmlRoot,act,c,n,ns,add,attr,o,i;
if(!xhr.responseXML || (xmlRoot=xhr.responseXML.documentElement)==null){
if(W.PHPDebug) alert('XML error: '+xhr.responseText);return r.cancel();
}
// Browse XML response nodes
for(i=0;i<xmlRoot.childNodes.length;i++) if((n=xmlRoot.childNodes[i]).nodeType==1){
if(n.firstChild) c=xmlRoot.childNodes[i].firstChild.nodeValue; else c='';
act=n.nodeName;
// Execute javascript
if(act=="JSAction") {
var c=(n.getAttribute('commitBuffer'))?geckoBuffer:c;
if(W.PHPDebug) {try{eval(c)} catch(e){alert('Async err: '+e+"\n"+c)}} else eval(c);
}
// Change node(s) innerHTML
if(act=="innerHTML"){
if(n.getAttribute('add')) add=true; else add=false;
ns=Array();
if(attr=n.getAttribute('nodeId')) ns[0]=dgi(attr);
else if(attr=n.getAttribute('nodeName')) ns=D.getElementsByName(attr);
else if(attr=n.getAttribute('nodeTagName')) ns=D.getElementsByTagName(attr);
for(o=0;o<ns.length;o++) if(ns[o]){
if(add) ns[o].innerHTML+=((n.getAttribute('commitBuffer'))?geckoBuffer:c);
else ns[o].innerHTML=((n.getAttribute('commitBuffer'))?geckoBuffer:c);
}
}
// Add data to gecko buffer
if(act=="addToBuffer") geckoBuffer+=c;
// Clear buffer
if(n.getAttribute('commitBuffer')) geckoBuffer='';
}
// Remove request from list, proceed to next in queue
r.cancel();
}
/**
* Cancel request function
*/
this.cancel=function(){wl.asr.cancel(this.id)}
return this.id;
}
// Set request-in-progress indicator
this.setRequestIndicator = function (st){
if(dgi('asyncRequestIndicator')) dgi('asyncRequestIndicator').style.display=(st)?'':'none';
else if(W.asyncRequestIndicator) asyncRequestIndicator(st);
else if(W.winMe) winMe.asyncRequestIndicator(st);
}
}
this.asr=new this.AsynchronousRequest();
}
var wl=new wJSLib();
// Legacy sendData function
function sendData(d,URL,force){return wl.asr.send(d,URL,0);}
/*********************************************************************************************
* Extended DOM node Object
*********************************************************************************************/
function $(node){
if(typeof node=='string') node=D.getElementById(node);
node.e=new wlNode(node);
return node;
}
function wlNode(node){this.n=node}
// Remove DOM node
wlNode.prototype.remove=function(){if((n=this.n) && n.parentNode) n.parentNode.removeChild(n)}
// Get actual style value, from style or css
wlNode.prototype.getStyle=function(styleProp){
if(!(n=this.n)) return;
if (n.currentStyle) return n.currentStyle[styleProp];
else if (W.getComputedStyle) return D.defaultView.getComputedStyle(n,null).getPropertyValue(styleProp);
}
// Set transparency (0<alpha<1)
wlNode.prototype.setAlpha=function(alpha){setAlpha(this.n,alpha)}
// offsets from top-left corner of document
wlNode.prototype.actualOffsetLeft=function(){return actualOffsetLeft(this.n)}
wlNode.prototype.actualOffsetRight=function(){return actualOffsetRight(this.n)}
wlNode.prototype.actualOffsetTop=function(){return actualOffsetTop(this.n)}
wlNode.prototype.actualOffsetBottom=function(){return actualOffsetBottom(this.n)}
// Center item on page
// Optional: offX & offY: offset (used to tweak position)
wlNode.prototype.center=function(offX,offY){
var w,h,l,t,n=this.n;
if(W.winMe){w=winMe.getInnerWidth();h=winMe.getInnerHeight()} else if(W.dd){w=dd.getWndW();h=dd.getWndH()}
l=(w-n.offsetWidth )/2+((W.pageXOffset)?W.pageXOffset:D.body.scrollLeft)+((offX)?offX:0);
t=(h-n.offsetHeight)/2+((W.pageYOffset)?W.pageYOffset:D.body.scrollTop)+((offY)?offY:0);
if(W.dd && n.id && dd.elements[n.id]) dd.elements[n.id].moveTo(l,t);
else with(n.style){left=l;top=t;}
}
// Extended DOM node class functions
wlNode.prototype.className=function(){return new wlNodeClass(this.n)}
wlNodeClass=function(node){this.n=node}
// Add a class to node
wlNodeClass.prototype.add=function(cl){
if(!(n=this.n)) return; // No node
if(!n.className) return n.className=cl; // Node has no class
if(n.className.indexOf(cl)!=-1) return; // Node already has class
n.className=n.className?n.className+' '+cl:cl;
}
// Remove a class from node
wlNodeClass.prototype.remove=function(cl){
if(!(n=this.n) || !n.className) return; // No node or no class
n.className=n.className.replace(new RegExp("[ ]{0,1}"+cl),"")
}
// Check if node has a class
wlNodeClass.prototype.has=function(cl){return (this.n && this.n.className)?(this.n.className.indexOf(cl)!=-1):0}
// Script load monitoring
if(W.lFunc) lFunc('common',50);